<!--科技学分认定-->
<template>
  <div id="documentaryCommit">
    <form class="form-horizontal">
      <div class="form-group">
        <label  class="col-sm-2 control-label">学号</label>
        <div class="col-sm-10">
          <input  class="form-control" v-model="studentNumber">
        </div>
      </div>
      <div class="form-group">
        <label  class="col-sm-2 control-label">项目</label>
        <div class="col-sm-10">
          <select class="col-sm-12"  v-model="projectNumber" style="width: 100%">
            <option v-for="project in projects" :value="project.id">{{project.myContent}}</option>
          </select>
        </div>
      </div>
      <div class="form-group">
        <label  class="col-sm-2 control-label">分数</label>
        <div class="col-sm-10">
          <input class="form-control" v-model="score" placeholder="加分为正，扣分为负">
        </div>
      </div>
      <div class="form-group">
        <label  class="col-sm-2 control-label">备注</label>
        <div class="col-sm-10">
          <input class="form-control" v-model="text">
        </div>
      </div>

      <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
          <button type="submit" class="btn btn-default" @click="mySubmit()">提交申请</button>
        </div>
      </div>
    </form>
    <h3>详细文档</h3>
    <p v-for="project in projects">{{project.content}}</p>
  </div>
</template>


<script>
  import API from '../config/request';

  export default {
    name : 'documentaryCommit',
    data () {
      return {
        url: API.URL,
        selected: 1 ,
        projects:[],
        studentNumber:'',
        projectNumber:'',
        score:'',
        text:''
      }
    },
    created() {
      this.getProject()
    },
    methods : {
      //拿到所有项目
      getProject: function () {
        this.$http.get(this.url+'doc').then(function (response) {
          for(let i in response.body){
            //console.log(response.body[i].content.split('——')[0])
            response.body[i].myContent = response.body[i].content.split('——')[0].trim()
          }
          this.projects = response.body
        })
      },
      mySubmit: function () {
        this.$http.get(this.url+'documentary/setDocumentary?studentNumber='+this.studentNumber
        +'&&projectNumber='+this.projectNumber+'&&score='+this.score+'&&text='+this.text).then(function (response) {
          if(response.body.code == 1){
            alert("提交成功");
            this.studentNumber = ''
            this.projectNumber = ''
            this.score = ''
            this.text = ''
          }
        })
      }
    }

  }

</script>

<style scoped>
  @import "../../node_modules/bootstrap/dist/css/bootstrap.min.css";
  @import "../assets/font-awesome-4.1.0/css/font-awesome.min.css";
  table.dataTable thead .sorting_asc:after {
    content: "\f0de";
    float: right;
    font-family: fontawesome;
  }

  table.dataTable thead .sorting_desc:after {
    content: "\f0dd";
    float: right;
    font-family: fontawesome;
  }

  table.dataTable thead .sorting:after {
    content: "\f0dc";
    float: right;
    font-family: fontawesome;
    color: rgba(50,50,50,.5);
  }

</style>
